<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAgentSdkBalanceOperationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('agent_sdk_balance_operations', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('agent_id')->index()->comment('代理商 ID');
            $table->bigInteger('channel_id')->comment('渠道 ID; 1:目前只有接龙小程序');
            $table->tinyInteger('revenues_type')->default(1)->comment('收支类型; 1:转入 2:转出');
            $table->unsignedBigInteger('amount')->default(0)->comment('金额 (单位 分) 始终是正数 由收支类型决定意义');
            $table->char('numbering', 22)->unique()->comment('我方操作编号');
            $table->char('origin_numbering', 32)->unique()->comment('对方操作编号');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('agent_sdk_balance_operations');
    }
}
